<?php

/**
 *@作者:MissZhang
 *@邮箱:<787727147@qq.com>
 *@创建时间:2022/10/13 09:38
 *@说明:认养订单额外收益模型
 */
namespace app\common\model;


use think\Model;

class FosterOrderExtra extends Model
{
    protected $pk = "id";
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    protected $type=[
        'lq_number'     =>  'float',
    ];
    public function getPkAttr($value,$data) {
        return $this->pk;
    }
    public function user(){
        return $this->hasOne(Users::class, 'user_id','user_id');
    }
    public function dingdan(){
        return $this->hasOne(FosterOrder::class, 'order_id','oid');
    }
    public function qianbao(){
        return $this->hasOne(Wallet::class, 'id','extra_wid');
    }
    public function getStatusTextAttr($value,$data) {
        $status = [-1=>'待领取',1=>'已领取'];
        return $status[$data['status']];
    }
    public function getLqTimeTextAttr($value,$data) {
        if ($data['lq_time']){
            return date($this->dateFormat,$data['lq_time']);
        }
        return '---';
    }
    public function getEndTimeTextAttr($value,$data) {
        if ($data['end_time']){
            return date($this->dateFormat,$data['end_time']);
        }
        return '---';
    }
}
